using System;
 using System.Collections.Generic;
 using System.Text;
 using System.Data;
 using System.Data.SqlClient;
 using MinhTam.DataAccess.Web;
//───────────────────────────────────────────────────────────────────────────────────────
 namespace MinhTam.Objects
  { 
 public class VAN_PHONG:  SQLConnectWeb { 
 public static string sTableName= "VAN_PHONG"; 
   public string VAN_PHONG_ID;
   public string TEN_VAN_PHONG;
   public string DIA_CHI;
   public string DIEN_THOAI;
   public string FAX;
   public string TINH_THANH_ID;
   public string MO_TA;
   public string MAP_URL;
   public string LOAI_VP_ID;
   public string HOT_LINE;
   public string EMAIl;
   public string IS_LIEN_HE;
   #region DataColumn Name ;
 public static  string cl_VAN_PHONG_ID="VAN_PHONG_ID" ;
 public static  string cl_TEN_VAN_PHONG="TEN_VAN_PHONG" ;
 public static  string cl_DIA_CHI="DIA_CHI" ;
 public static  string cl_DIEN_THOAI="DIEN_THOAI" ;
 public static  string cl_FAX="FAX" ;
 public static  string cl_TINH_THANH_ID="TINH_THANH_ID" ;
 public static  string cl_MO_TA="MO_TA" ;
 public static  string cl_MAP_URL="MAP_URL" ;
 public static  string cl_LOAI_VP_ID="LOAI_VP_ID" ;
 public static  string cl_HOT_LINE="HOT_LINE" ;
 public static  string cl_EMAIl="EMAIl" ;
 public static  string cl_IS_LIEN_HE="IS_LIEN_HE" ;
 #endregion;
//───────────────────────────────────────────────────────────────────────────────────────
       public VAN_PHONG() {}
//───────────────────────────────────────────────────────────────────────────────────────
       public VAN_PHONG(
         string sVAN_PHONG_ID,
         string sTEN_VAN_PHONG,
         string sDIA_CHI,
         string sDIEN_THOAI,
         string sFAX,
         string sTINH_THANH_ID,
         string sMO_TA,
         string sMAP_URL,
         string sLOAI_VP_ID,
         string sHOT_LINE,
         string sEMAIl,
         string sIS_LIEN_HE){
         this.VAN_PHONG_ID= sVAN_PHONG_ID;
         this.TEN_VAN_PHONG= sTEN_VAN_PHONG;
         this.DIA_CHI= sDIA_CHI;
         this.DIEN_THOAI= sDIEN_THOAI;
         this.FAX= sFAX;
         this.TINH_THANH_ID= sTINH_THANH_ID;
         this.MO_TA= sMO_TA;
         this.MAP_URL= sMAP_URL;
         this.LOAI_VP_ID= sLOAI_VP_ID;
         this.HOT_LINE= sHOT_LINE;
         this.EMAIl= sEMAIl;
         this.IS_LIEN_HE= sIS_LIEN_HE;
}
//───────────────────────────────────────────────────────────────────────────────────────
       public static VAN_PHONG Create_VAN_PHONG ( string sVAN_PHONG_ID  ){
    DataTable dt=SearchByVAN_PHONG_ID(sVAN_PHONG_ID) ;
    if(dt!=null && dt.Rows.Count>0) 
      return new VAN_PHONG(dt,0);
      return null;
}
//───────────────────────────────────────────────────────────────────────────────────────
   private static string s_Select()
    {
   return " SELECT T.* FROM VAN_PHONG AS T";
    }
//───────────────────────────────────────────────────────────────────────────────────────
 public VAN_PHONG( DataTable table,int pos)
{
         this.VAN_PHONG_ID= table.Rows[pos]["VAN_PHONG_ID"].ToString();
         this.TEN_VAN_PHONG= table.Rows[pos]["TEN_VAN_PHONG"].ToString();
         this.DIA_CHI= table.Rows[pos]["DIA_CHI"].ToString();
         this.DIEN_THOAI= table.Rows[pos]["DIEN_THOAI"].ToString();
         this.FAX= table.Rows[pos]["FAX"].ToString();
         this.TINH_THANH_ID= table.Rows[pos]["TINH_THANH_ID"].ToString();
         this.MO_TA= table.Rows[pos]["MO_TA"].ToString();
         this.MAP_URL= table.Rows[pos]["MAP_URL"].ToString();
         this.LOAI_VP_ID= table.Rows[pos]["LOAI_VP_ID"].ToString();
         this.HOT_LINE= table.Rows[pos]["HOT_LINE"].ToString();
         this.EMAIl= table.Rows[pos]["EMAIl"].ToString();
         this.IS_LIEN_HE= table.Rows[pos]["IS_LIEN_HE"].ToString();
}
//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByVAN_PHONG_ID(string sVAN_PHONG_ID)
{
          string sqlSelect= s_Select()+ " WHERE VAN_PHONG_ID  ="+ sVAN_PHONG_ID + ""; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByVAN_PHONG_ID(string sVAN_PHONG_ID,string sMatch)
{
          string sqlSelect= s_Select()+ " WHERE VAN_PHONG_ID"+ sMatch +sVAN_PHONG_ID + ""; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByTEN_VAN_PHONG(string sTEN_VAN_PHONG)
{
          string sqlSelect= s_Select()+ " WHERE TEN_VAN_PHONG  Like N'%"+ sTEN_VAN_PHONG + "%'"; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByDIA_CHI(string sDIA_CHI)
{
          string sqlSelect= s_Select()+ " WHERE DIA_CHI  Like N'%"+ sDIA_CHI + "%'"; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByDIEN_THOAI(string sDIEN_THOAI)
{
          string sqlSelect= s_Select()+ " WHERE DIEN_THOAI  Like N'%"+ sDIEN_THOAI + "%'"; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByFAX(string sFAX)
{
          string sqlSelect= s_Select()+ " WHERE FAX  Like N'%"+ sFAX + "%'"; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByTINH_THANH_ID(string sTINH_THANH_ID)
{
          string sqlSelect= s_Select()+ " WHERE TINH_THANH_ID  ="+ sTINH_THANH_ID + ""; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByTINH_THANH_ID(string sTINH_THANH_ID,string sMatch)
{
          string sqlSelect= s_Select()+ " WHERE TINH_THANH_ID"+ sMatch +sTINH_THANH_ID + ""; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByMO_TA(string sMO_TA)
{
          string sqlSelect= s_Select()+ " WHERE MO_TA  Like '%"+ sMO_TA + "%'"; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByMAP_URL(string sMAP_URL)
{
          string sqlSelect= s_Select()+ " WHERE MAP_URL  Like '%"+ sMAP_URL + "%'"; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByLOAI_VP_ID(string sLOAI_VP_ID)
{
          string sqlSelect= s_Select()+ " WHERE LOAI_VP_ID  ="+ sLOAI_VP_ID + ""; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByLOAI_VP_ID(string sLOAI_VP_ID,string sMatch)
{
          string sqlSelect= s_Select()+ " WHERE LOAI_VP_ID"+ sMatch +sLOAI_VP_ID + ""; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByHOT_LINE(string sHOT_LINE)
{
          string sqlSelect= s_Select()+ " WHERE HOT_LINE  Like N'%"+ sHOT_LINE + "%'"; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByEMAIl(string sEMAIl)
{
          string sqlSelect= s_Select()+ " WHERE EMAIl  Like N'%"+ sEMAIl + "%'"; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable SearchByIS_LIEN_HE(string sIS_LIEN_HE)
{
          string sqlSelect= s_Select()+ " WHERE IS_LIEN_HE  Like N'%"+ sIS_LIEN_HE + "%'"; 
          DataTable dt=GetTable(sqlSelect,sTableName) ;
          return dt; 
 }//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable Search( string sVAN_PHONG_ID
            , string sTEN_VAN_PHONG
            , string sDIA_CHI
            , string sDIEN_THOAI
            , string sFAX
            , string sTINH_THANH_ID
            , string sMO_TA
            , string sMAP_URL
            , string sLOAI_VP_ID
            , string sHOT_LINE
            , string sEMAIl
            , string sIS_LIEN_HE
            )
 {
       string sqlselect=s_Select() + " WHERE" ;
      if (sVAN_PHONG_ID!=null && sVAN_PHONG_ID!="") 
            sqlselect +=" AND VAN_PHONG_ID =" + sVAN_PHONG_ID ;
      if (sTEN_VAN_PHONG!=null && sTEN_VAN_PHONG!="") 
            sqlselect +=" AND TEN_VAN_PHONG LIKE N'%" + sTEN_VAN_PHONG +"%'" ;
      if (sDIA_CHI!=null && sDIA_CHI!="") 
            sqlselect +=" AND DIA_CHI LIKE N'%" + sDIA_CHI +"%'" ;
      if (sDIEN_THOAI!=null && sDIEN_THOAI!="") 
            sqlselect +=" AND DIEN_THOAI LIKE N'%" + sDIEN_THOAI +"%'" ;
      if (sFAX!=null && sFAX!="") 
            sqlselect +=" AND FAX LIKE N'%" + sFAX +"%'" ;
      if (sTINH_THANH_ID!=null && sTINH_THANH_ID!="") 
            sqlselect +=" AND TINH_THANH_ID =" + sTINH_THANH_ID ;
      if (sMO_TA!=null && sMO_TA!="") 
            sqlselect +=" AND MO_TA LIKE '%" + sMO_TA +"%'" ;
      if (sMAP_URL!=null && sMAP_URL!="") 
            sqlselect +=" AND MAP_URL LIKE '%" + sMAP_URL +"%'" ;
      if (sLOAI_VP_ID!=null && sLOAI_VP_ID!="") 
            sqlselect +=" AND LOAI_VP_ID =" + sLOAI_VP_ID ;
      if (sHOT_LINE!=null && sHOT_LINE!="") 
            sqlselect +=" AND HOT_LINE LIKE N'%" + sHOT_LINE +"%'" ;
      if (sEMAIl!=null && sEMAIl!="") 
            sqlselect +=" AND EMAIl LIKE N'%" + sEMAIl +"%'" ;
      if (sIS_LIEN_HE!=null && sIS_LIEN_HE!="") 
            sqlselect +=" AND IS_LIEN_HE LIKE N'%" + sIS_LIEN_HE +"%'" ;
   sqlselect=sqlselect.Replace("WHERE AND","WHERE");
   int n=sqlselect.IndexOf("WHERE");
   if(n==sqlselect.Length -5) sqlselect=sqlselect.Remove(n,5) ;
   return GetTable(sqlselect,sTableName);
}
//───────────────────────────────────────────────────────────────────────────────────────
 public static VAN_PHONG Insert_Object(
string  sTEN_VAN_PHONG
            ,string  sDIA_CHI
            ,string  sDIEN_THOAI
            ,string  sFAX
            ,string  sTINH_THANH_ID
            ,string  sMO_TA
            ,string  sMAP_URL
            ,string  sLOAI_VP_ID
            ,string  sHOT_LINE
            ,string  sEMAIl
            ,string  sIS_LIEN_HE
            ) 
 { 
              string tem_sTEN_VAN_PHONG=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sTEN_VAN_PHONG,"nvarchar");
              string tem_sDIA_CHI=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sDIA_CHI,"nvarchar");
              string tem_sDIEN_THOAI=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sDIEN_THOAI,"varchar");
              string tem_sFAX=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sFAX,"varchar");
              string tem_sTINH_THANH_ID=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sTINH_THANH_ID,"int");
              string tem_sMO_TA=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sMO_TA,"ntext");
              string tem_sMAP_URL=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sMAP_URL,"ntext");
              string tem_sLOAI_VP_ID=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sLOAI_VP_ID,"int");
              string tem_sHOT_LINE=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sHOT_LINE,"varchar");
              string tem_sEMAIl=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sEMAIl,"nvarchar");
              string tem_sIS_LIEN_HE=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sIS_LIEN_HE,"char");

             string sqlSave=" INSERT INTO VAN_PHONG("+
                   "TEN_VAN_PHONG," 
        +                   "DIA_CHI," 
        +                   "DIEN_THOAI," 
        +                   "FAX," 
        +                   "TINH_THANH_ID," 
        +                   "MO_TA," 
        +                   "MAP_URL," 
        +                   "LOAI_VP_ID," 
        +                   "HOT_LINE," 
        +                   "EMAIl," 
        +                   "IS_LIEN_HE) VALUES("
 +tem_sTEN_VAN_PHONG+","
 +tem_sDIA_CHI+","
 +tem_sDIEN_THOAI+","
 +tem_sFAX+","
 +tem_sTINH_THANH_ID+","
 +tem_sMO_TA+","
 +tem_sMAP_URL+","
 +tem_sLOAI_VP_ID+","
 +tem_sHOT_LINE+","
 +tem_sEMAIl+","
 +tem_sIS_LIEN_HE +")";
             bool OK = Exec(sqlSave)>=1?true:false;
           if (OK) 
           { 
          VAN_PHONG newVAN_PHONG= new VAN_PHONG();
                 newVAN_PHONG.VAN_PHONG_ID=GetTable( " SELECT TOP 1 VAN_PHONG_ID FROM VAN_PHONG ORDER BY VAN_PHONG_ID DESC ").Rows[0][0].ToString();
              newVAN_PHONG.TEN_VAN_PHONG=sTEN_VAN_PHONG;
              newVAN_PHONG.DIA_CHI=sDIA_CHI;
              newVAN_PHONG.DIEN_THOAI=sDIEN_THOAI;
              newVAN_PHONG.FAX=sFAX;
              newVAN_PHONG.TINH_THANH_ID=sTINH_THANH_ID;
              newVAN_PHONG.MO_TA=sMO_TA;
              newVAN_PHONG.MAP_URL=sMAP_URL;
              newVAN_PHONG.LOAI_VP_ID=sLOAI_VP_ID;
              newVAN_PHONG.HOT_LINE=sHOT_LINE;
              newVAN_PHONG.EMAIl=sEMAIl;
              newVAN_PHONG.IS_LIEN_HE=sIS_LIEN_HE;
            return newVAN_PHONG; 
           } 
           else return null ;
}
//───────────────────────────────────────────────────────────────────────────────────────
public bool  Save_Object(string sTEN_VAN_PHONG
                ,string sDIA_CHI
                ,string sDIEN_THOAI
                ,string sFAX
                ,string sTINH_THANH_ID
                ,string sMO_TA
                ,string sMAP_URL
                ,string sLOAI_VP_ID
                ,string sHOT_LINE
                ,string sEMAIl
                ,string sIS_LIEN_HE
                ) 
 { 
              string tem_sTEN_VAN_PHONG=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sTEN_VAN_PHONG,"nvarchar");
              string tem_sDIA_CHI=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sDIA_CHI,"nvarchar");
              string tem_sDIEN_THOAI=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sDIEN_THOAI,"varchar");
              string tem_sFAX=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sFAX,"varchar");
              string tem_sTINH_THANH_ID=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sTINH_THANH_ID,"int");
              string tem_sMO_TA=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sMO_TA,"ntext");
              string tem_sMAP_URL=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sMAP_URL,"ntext");
              string tem_sLOAI_VP_ID=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sLOAI_VP_ID,"int");
              string tem_sHOT_LINE=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sHOT_LINE,"varchar");
              string tem_sEMAIl=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sEMAIl,"nvarchar");
              string tem_sIS_LIEN_HE=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sIS_LIEN_HE,"char");

 string sqlSave=" UPDATE VAN_PHONG SET "+"TEN_VAN_PHONG ="+tem_sTEN_VAN_PHONG+","
 +"DIA_CHI ="+tem_sDIA_CHI+","
 +"DIEN_THOAI ="+tem_sDIEN_THOAI+","
 +"FAX ="+tem_sFAX+","
 +"TINH_THANH_ID ="+tem_sTINH_THANH_ID+","
 +"MO_TA ="+tem_sMO_TA+","
 +"MAP_URL ="+tem_sMAP_URL+","
 +"LOAI_VP_ID ="+tem_sLOAI_VP_ID+","
 +"HOT_LINE ="+tem_sHOT_LINE+","
 +"EMAIl ="+tem_sEMAIl+","
 +"IS_LIEN_HE ="+tem_sIS_LIEN_HE+" WHERE VAN_PHONG_ID="+MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(this.VAN_PHONG_ID,"int identity");;
              bool OK = Exec(sqlSave)>=1?true:false;
           if (OK) 
           { 
                this.TEN_VAN_PHONG=sTEN_VAN_PHONG;
                this.DIA_CHI=sDIA_CHI;
                this.DIEN_THOAI=sDIEN_THOAI;
                this.FAX=sFAX;
                this.TINH_THANH_ID=sTINH_THANH_ID;
                this.MO_TA=sMO_TA;
                this.MAP_URL=sMAP_URL;
                this.LOAI_VP_ID=sLOAI_VP_ID;
                this.HOT_LINE=sHOT_LINE;
                this.EMAIl=sEMAIl;
                this.IS_LIEN_HE=sIS_LIEN_HE;
           } 
 return OK;  }
//───────────────────────────────────────────────────────────────────────────────────────
 #region Update DataColumn  
 public bool Update_VAN_PHONG_ID(string sVAN_PHONG_ID)
{
    string sqlSave= " UPDATE VAN_PHONG SET VAN_PHONG_ID='"+ sVAN_PHONG_ID+ "' WHERE VAN_PHONG_ID='"+ this.VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 if(OK)
 {
    this.VAN_PHONG_ID=sVAN_PHONG_ID;
 }
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public bool Update_TEN_VAN_PHONG(string sTEN_VAN_PHONG)
{
    string sqlSave= " UPDATE VAN_PHONG SET TEN_VAN_PHONG='N"+ sTEN_VAN_PHONG+ "' WHERE VAN_PHONG_ID='"+ this.VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 if(OK)
 {
    this.TEN_VAN_PHONG=sTEN_VAN_PHONG;
 }
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public bool Update_DIA_CHI(string sDIA_CHI)
{
    string sqlSave= " UPDATE VAN_PHONG SET DIA_CHI='N"+ sDIA_CHI+ "' WHERE VAN_PHONG_ID='"+ this.VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 if(OK)
 {
    this.DIA_CHI=sDIA_CHI;
 }
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public bool Update_DIEN_THOAI(string sDIEN_THOAI)
{
    string sqlSave= " UPDATE VAN_PHONG SET DIEN_THOAI='N"+ sDIEN_THOAI+ "' WHERE VAN_PHONG_ID='"+ this.VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 if(OK)
 {
    this.DIEN_THOAI=sDIEN_THOAI;
 }
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public bool Update_FAX(string sFAX)
{
    string sqlSave= " UPDATE VAN_PHONG SET FAX='N"+ sFAX+ "' WHERE VAN_PHONG_ID='"+ this.VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 if(OK)
 {
    this.FAX=sFAX;
 }
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public bool Update_TINH_THANH_ID(string sTINH_THANH_ID)
{
    string sqlSave= " UPDATE VAN_PHONG SET TINH_THANH_ID='"+ sTINH_THANH_ID+ "' WHERE VAN_PHONG_ID='"+ this.VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 if(OK)
 {
    this.TINH_THANH_ID=sTINH_THANH_ID;
 }
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public bool Update_MO_TA(string sMO_TA)
{
    string sqlSave= " UPDATE VAN_PHONG SET MO_TA='"+ sMO_TA+ "' WHERE VAN_PHONG_ID='"+ this.VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 if(OK)
 {
    this.MO_TA=sMO_TA;
 }
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public bool Update_MAP_URL(string sMAP_URL)
{
    string sqlSave= " UPDATE VAN_PHONG SET MAP_URL='"+ sMAP_URL+ "' WHERE VAN_PHONG_ID='"+ this.VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 if(OK)
 {
    this.MAP_URL=sMAP_URL;
 }
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public bool Update_LOAI_VP_ID(string sLOAI_VP_ID)
{
    string sqlSave= " UPDATE VAN_PHONG SET LOAI_VP_ID='"+ sLOAI_VP_ID+ "' WHERE VAN_PHONG_ID='"+ this.VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 if(OK)
 {
    this.LOAI_VP_ID=sLOAI_VP_ID;
 }
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public bool Update_HOT_LINE(string sHOT_LINE)
{
    string sqlSave= " UPDATE VAN_PHONG SET HOT_LINE='N"+ sHOT_LINE+ "' WHERE VAN_PHONG_ID='"+ this.VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 if(OK)
 {
    this.HOT_LINE=sHOT_LINE;
 }
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public bool Update_EMAIl(string sEMAIl)
{
    string sqlSave= " UPDATE VAN_PHONG SET EMAIl='N"+ sEMAIl+ "' WHERE VAN_PHONG_ID='"+ this.VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 if(OK)
 {
    this.EMAIl=sEMAIl;
 }
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public bool Update_IS_LIEN_HE(string sIS_LIEN_HE)
{
    string sqlSave= " UPDATE VAN_PHONG SET IS_LIEN_HE='N"+ sIS_LIEN_HE+ "' WHERE VAN_PHONG_ID='"+ this.VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 if(OK)
 {
    this.IS_LIEN_HE=sIS_LIEN_HE;
 }
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 #endregion
 #region Update DataColumn  Static 
 public static bool Update_TEN_VAN_PHONG(string sTEN_VAN_PHONG,string s_VAN_PHONG_ID)
{
  string sqlSave= " UPDATE VAN_PHONG SET TEN_VAN_PHONG='N"+sTEN_VAN_PHONG+"' WHERE VAN_PHONG_ID='"+ s_VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public static bool Update_DIA_CHI(string sDIA_CHI,string s_VAN_PHONG_ID)
{
  string sqlSave= " UPDATE VAN_PHONG SET DIA_CHI='N"+sDIA_CHI+"' WHERE VAN_PHONG_ID='"+ s_VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public static bool Update_DIEN_THOAI(string sDIEN_THOAI,string s_VAN_PHONG_ID)
{
  string sqlSave= " UPDATE VAN_PHONG SET DIEN_THOAI='N"+sDIEN_THOAI+"' WHERE VAN_PHONG_ID='"+ s_VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public static bool Update_FAX(string sFAX,string s_VAN_PHONG_ID)
{
  string sqlSave= " UPDATE VAN_PHONG SET FAX='N"+sFAX+"' WHERE VAN_PHONG_ID='"+ s_VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public static bool Update_TINH_THANH_ID(string sTINH_THANH_ID,string s_VAN_PHONG_ID)
{
  string sqlSave= " UPDATE VAN_PHONG SET TINH_THANH_ID='"+sTINH_THANH_ID+"' WHERE VAN_PHONG_ID='"+ s_VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public static bool Update_MO_TA(string sMO_TA,string s_VAN_PHONG_ID)
{
  string sqlSave= " UPDATE VAN_PHONG SET MO_TA='"+sMO_TA+"' WHERE VAN_PHONG_ID='"+ s_VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public static bool Update_MAP_URL(string sMAP_URL,string s_VAN_PHONG_ID)
{
  string sqlSave= " UPDATE VAN_PHONG SET MAP_URL='"+sMAP_URL+"' WHERE VAN_PHONG_ID='"+ s_VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public static bool Update_LOAI_VP_ID(string sLOAI_VP_ID,string s_VAN_PHONG_ID)
{
  string sqlSave= " UPDATE VAN_PHONG SET LOAI_VP_ID='"+sLOAI_VP_ID+"' WHERE VAN_PHONG_ID='"+ s_VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public static bool Update_HOT_LINE(string sHOT_LINE,string s_VAN_PHONG_ID)
{
  string sqlSave= " UPDATE VAN_PHONG SET HOT_LINE='N"+sHOT_LINE+"' WHERE VAN_PHONG_ID='"+ s_VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public static bool Update_EMAIl(string sEMAIl,string s_VAN_PHONG_ID)
{
  string sqlSave= " UPDATE VAN_PHONG SET EMAIl='N"+sEMAIl+"' WHERE VAN_PHONG_ID='"+ s_VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
 public static bool Update_IS_LIEN_HE(string sIS_LIEN_HE,string s_VAN_PHONG_ID)
{
  string sqlSave= " UPDATE VAN_PHONG SET IS_LIEN_HE='N"+sIS_LIEN_HE+"' WHERE VAN_PHONG_ID='"+ s_VAN_PHONG_ID+"' ";
 bool OK=Exec(sqlSave)>=1?true:false;
 return OK;
}
//───────────────────────────────────────────────────────────────────────────────────────
#endregion
//───────────────────────────────────────────────────────────────────────────────────────
 public static DataTable GetTableAll() 
 {
       return  GetTableAll(null, null);
 }
public static DataTable GetTableAll(string sWhere, params string[] orderFields)
{
   string sqlSelect = " SELECT * FROM VAN_PHONG";
   if (!string.IsNullOrEmpty(sWhere))
      sqlSelect += " where " + sWhere; 
   string order = "";
   if (orderFields != null && orderFields.Length > 0)
     order = string.Join(",", orderFields);
   if (order != "")
      sqlSelect += " ORDER BY " + order;
   return GetTable(sqlSelect,sTableName);
}
//───────────────────────────────────────────────────────────────────────────────────────
//───────────────────────────────────────────────────────────────────────────────────────
public static DataTable GetTableFields(string sWhere, string[] orderFields, params string[] fields)
{
 string field = "";
 if (fields != null && fields.Length > 0)
    field = string.Join(",", fields);
 else field = "*";
 string sqlSelect = string.Format(" SELECT {0} FROM {1} ", field, "VAN_PHONG");
 if (!string.IsNullOrEmpty(sWhere))
    sqlSelect += " where " + sWhere;
 string order = "";
 if (orderFields != null && orderFields.Length > 0)
    order = string.Join(",", orderFields);
 if (order != "")
    sqlSelect += " ORDER BY " + order;
 return GetTable(sqlSelect,sTableName);
 }
 public static DataTable GetTableFields(params string[] fields)
 {
    return GetTableFields(null, null, fields);
 }
 public static DataTable GetTableFields(string[] orderFields, params string[] fields)
 {
    return GetTableFields(null, orderFields, fields);
 }
//───────────────────────────────────────────────────────────────────────────────────────
   private static DataTable dt_VAN_PHONG;
   public static bool Change_dt_VAN_PHONG = true;
   public static bool AllowAutoChange = true;
   public static DataTable get_VAN_PHONG()
   {
   if (dt_VAN_PHONG == null || Change_dt_VAN_PHONG == true)
     {
   dt_VAN_PHONG = GetTableAll();
         Change_dt_VAN_PHONG = true && AllowAutoChange ;
     }
     return dt_VAN_PHONG;
   }
   //───────────────────────────────────────────────────────────────────────────────────────
}  
 } 
